package com.dingreading.cloud.gateway.service.impl;

import com.dingreading.cloud.common.util.PageUtil;
import com.dingreading.cloud.gateway.entity.AdminRoles;
import com.dingreading.cloud.gateway.entity.table.AdminRolesTableDef;
import com.dingreading.cloud.gateway.mapper.AdminRolesMapper;
import com.dingreading.cloud.gateway.service.AdminRolesService;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
import org.springframework.stereotype.Service;


/**
 * 服务层实现。
 *
 * @author Administrator
 * @since 2023-11-22
 */
@Service
public class AdminRolesServiceImpl extends BaseServiceImpl<AdminRolesMapper, AdminRoles, AdminRolesTableDef> implements AdminRolesService {

    @Override
    protected AdminRolesTableDef getTable() {
        return AdminRolesTableDef.adminRoles;
    }

    @Override
    public Page<AdminRoles> pageList(PageUtil pageUtil) {

        QueryWrapper queryWrapper = QueryWrapper.create()
                .select()
                .from(table)
                .orderBy(table.id.asc());

        return getMapper().paginate(Page.of(pageUtil.getPage(), pageUtil.getRows()), queryWrapper);
    }

    @Override
    public int dropBean(Long roleId) {
        return getMapper().deleteById(roleId);
    }
}
